package com.eos.orm.mybatis.dao.impl;

import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

/**
 * 构建SqlSessionFactory对象抽象工厂
 * 
 * @author Administrator
 * 
 */
public abstract class AbstractSqlSessionFactory {
	public static SqlSessionFactory sqlSessionFactory = null;
	static {
		try {
			Reader reader = Resources.getResourceAsReader("mybatis-config.xml");
			// mybatis可以创建多个sqlSessionFactory，根据development环境变量参数来区分，以便达到操作多个数据库的目的
			sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader,
					"development");
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
